package com.xbongbong.saas.enums;


import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * 工单阶段操作枚举
 * @author 魏荣杰
 * @date 2019/3/29 10:41
 * @since v1.0
 * @version v1.0
 */
public enum WorkOrderStageOperationEnum {
    /**
     *
     */
    ACCEPT(1,"accept","enum.workOrderStageOperation.name.accept"),


    COMPLETE(2,"complete","enum.workOrderStageOperation.name.complete"),


    CLOSE(3,"close","enum.workOrderStageOperation.name.close"),


    ROLLBACK(4,"rollback","enum.workOrderStageOperation.name.rollback"),


    TRANSFER(5,"transfer","enum.workOrderStageOperation.name.transfer"),


    RESTART(6,"restart","enum.workOrderStageOperation.name.restart"),


    STAGE_COMPLETE(7,"stageComplete","enum.workOrderStageOperation.name.stage_complete"),


    UNKNOWN(404,"","enum.workOrderStageOperation.name.unknown")
    ;

    private int code;
    private String alias;
    private String name;

    WorkOrderStageOperationEnum(int code, String alias, String name){
        this.code = code;
        this.alias = alias;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public void setName(String name) {
        this.name = name;
    }
    /**
     * 根据alias获取枚举
     */
    public static WorkOrderStageOperationEnum getByAlias(String alias) {
        for (WorkOrderStageOperationEnum cache : values()) {
            if (alias.equals(cache.getAlias())) {
                return cache;
            }
        }
        return UNKNOWN;
    }

    /**
     * 通过枚举<code>code</code>获得枚举
     *
     * @param code
     * @return WxErrorCodeEnum
     */
    public static WorkOrderStageOperationEnum getByCode(Integer code) {
        for (WorkOrderStageOperationEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
    
}
